// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DepthIRColorCameraMessage.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Microsoft.Robotics.Vision.Runtime.Cameras
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.Text;
    using System.Threading.Tasks;

    using Microsoft.Robotics.Numerics;
    using Microsoft.Robotics.Runtime;
    using Microsoft.Robotics.Vision.Cameras;

    /// <summary>
    /// Message type that contains a synchronized depth and $IR$ camera message
    /// </summary>
    /// <typeparam name="TDepthParameters">The parameters for the depth camera</typeparam>
    /// <typeparam name="TIRParameters">The parameters for the $IR$ camera</typeparam>
    /// <typeparam name="TColorParameters">The parameters for the color camera</typeparam>
    [DataContract]
    [KnownType(typeof(ImageFrameDepth))]
    [KnownType(typeof(ImageFrameRgb))]
    public class DepthIRColorCameraMessage<TDepthParameters, TIRParameters, TColorParameters> : AgentMessage
        where TDepthParameters : DepthParameters
        where TIRParameters : IRParameters
        where TColorParameters : ColorParameters
    {
        /// <summary>
        /// Initializes a new instance of the DepthIRColorCameraMessage class
        /// </summary>
        /// <param name="originatingTime">The originating time of the message</param>
        /// <param name="depthCamera">The camera generating the depth image</param>
        /// <param name="irCamera">The camera generating the $IR$ image</param>
        /// <param name="colorCamera">Color message</param>
        public DepthIRColorCameraMessage(
            long originatingTime,
            DepthCameraAgentMessage<TDepthParameters> depthCamera,
            IRCameraAgentMessage<TIRParameters> irCamera,
            ColorCameraAgentMessage<TColorParameters> colorCamera)

            : base(originatingTime)
        {
            this.IRCamera = irCamera;
            this.DepthCamera = depthCamera;
            this.ColorCamera = colorCamera;
        }

        /// <summary>
        /// Gets the depth camera
        /// </summary>
        [DataMember]
        public DepthCameraAgentMessage<TDepthParameters> DepthCamera { get; private set; }

        /// <summary>
        /// Gets the IR camera
        /// </summary>
        [DataMember]
        public IRCameraAgentMessage<TIRParameters> IRCamera { get; private set; }

        /// <summary>
        /// Gets the color message
        /// </summary>
        [DataMember]
        public ColorCameraAgentMessage<TColorParameters> ColorCamera { get; private set; }

        /// <summary>
        /// Gets the Depth frame
        /// </summary>
        [DataMember]
        public ImageFrameDepth DepthFrame
        {
            get
            {
                if (null != this.DepthCamera)
                {
                    return this.DepthCamera.DepthFrame;
                }
                else
                {
                    return null;
                }
            }

            private set
            {
            }
        }

        /// <summary>
        /// Gets the Depth frame
        /// </summary>
        [DataMember]
        public ImageFrame<ushort> IRFrame
        {
            get
            {
                if (null != this.IRCamera)
                {
                    return this.IRCamera.ImageFrame;
                }
                else
                {
                    return null;
                }
            }

            private set 
            {
            }
        }

        /// <summary>
        /// Gets the Depth frame
        /// </summary>
        [DataMember]
        public ImageFrameRgb ColorFrame
        {
            get
            {
                if (null != this.ColorCamera)
                {
                    return this.ColorCamera.ColorFrame;
                }
                else
                {
                    return null;
                }
            }

            private set
            {
            }
        }
    }
}
